package com.ope.web.controller.chainresponsibility;
import com.ope.web.model.DTO.ProcessMointorRequestBody;
import lombok.extern.slf4j.Slf4j;



/**
 * @description: 解析父类
 * @author: fxr
 * @create: 2024年12月24日16:49:53
 */
@Slf4j
public abstract class TopicAnalysisHandle implements TopicAnalysis {


    private TopicAnalysis next;


    @Override
    public void decode(ProcessMointorRequestBody processMointorRequestBody) {
        log.info("子报文:{}", processMointorRequestBody);
        if (matchDecoder(processMointorRequestBody, processMointorRequestBody.getProcessName())) {
            process(processMointorRequestBody);
        } else {
            if (next != null) {
                next.decode(processMointorRequestBody);
            }
        }
    }

    /**
     * 子类重写
     *
     * @param processMointorRequestBody processMointorRequestBody
     * @return
     */
    protected abstract void process(ProcessMointorRequestBody processMointorRequestBody);


    @Override
    public void setNext(TopicAnalysis next) {
        this.next = next;
    }

    @Override
    public TopicAnalysis getNext() {
        return this.next;
    }
}
